package com.sx.gongzhong.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sx.gongzhong.R;
import com.sx.gongzhong.model.CommentBean;
import com.sx.gongzhong.net.ServiceFactory;

import java.util.List;

/**答復
 * Created by admin on 2018/1/4.
 */

public class ReplyListAdapter  extends BaseQuickAdapter<CommentBean,BaseViewHolder> {

    private Context context;

    public ReplyListAdapter(Context context, @LayoutRes int layoutResId, @Nullable List<CommentBean> data) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentBean item) {
        helper.setText(R.id.tv_commentTime,item.replyTime);
        helper.setText(R.id.tv_Content,item.content);
        if (item.replyUser != null){
            helper.setText(R.id.tv_Name,item.replyUser.getName());
            RequestOptions options = new RequestOptions().centerCrop()
                    .placeholder(R.mipmap.img_head_default)
                    .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                    .circleCrop()
                    .error(R.mipmap.img_head_default);
            Glide.with(context)
                    .load(ServiceFactory.getUrl(item.replyUser.getHeaderUrl()))
                    .apply(options)
                    .into((ImageView) helper.getView(R.id.im_headerUrl));
        }
    }
}
